package com.ny.view;

import com.ny.entity.Product;
import com.ny.entity.Stud;
import com.ny.service.impl.ProductServiceImpl;
import com.ny.service.impl.StudentServiceImpl;

import java.sql.SQLException;
import java.util.List;

public class SelectView {
    public static void showSelectStudForm() throws ClassNotFoundException, SQLException, SQLException {
        StudentServiceImpl studentService = new StudentServiceImpl();
        List<Stud> list = studentService.findAllStud();
        for (Stud stud : list) {
            System.out.println(stud);
        }
    }

    public static void showSelectProForm() throws ClassNotFoundException, SQLException, SQLException, SQLException {
        ProductServiceImpl productService = new ProductServiceImpl();
        List<Product> list = productService.findAllProduct();
        System.out.println("商品id" + "\t" + "\t" + "商品名称" + "\t" + "商品价格" + "\t" + "商品库存" + "\t" + "商品类别" + "\t" + "商品描述");
        for (Product product : list) {
            System.out.print(product.getProduct_id());
            System.out.print("\t" + "\t");
            System.out.print(product.getName());
            System.out.print("\t" + "\t");
            System.out.print(product.getPrice());
            System.out.print("\t" + "\t");
            System.out.print(product.getStock());
            System.out.print("\t" + "\t");
            System.out.print(product.getCategory());
            System.out.print("\t" + "\t");
            System.out.println(product.getDescription());
            System.out.println("\t"+ "\t");
        }
    }

}
